import {  Controller,  Get,  Post,  Put,  Delete,Body,Param,} from '@nestjs/common';
import { Student } from './student.entity';
import { StudentsService } from './student.service';
@Controller('students')
export class StudentsController {
  constructor(private readonly studentsService: StudentsService) {}
  @Get()
  findAll(): Promise<Student[]> {
    return this.studentsService.findAll();
  }
  @Get(':id')
  findOne(@Param('id') id: string): Promise<Student | null> {
    return this.studentsService.findOne(Number(id));
  }
  @Post()
  create(@Body() student: Student): Promise<Student> {
    return this.studentsService.create(student);
  }
  @Put(':id')
  update(
    @Param('id') id: string,
    @Body() student: Student,
  ): Promise<void> {
    return this.studentsService.update(Number(id), student);
  }
  @Delete(':id')
  remove(@Param('id') id: string): Promise<void> {
    return this.studentsService.remove(Number(id));
  }
}